<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>超雪官网最新iccid</title>
    <link rel="shortcut icon" href="https://assets.shimonote.com/from_qbox/sheet_favicon.ico">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="CryptoJS.js"></script>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    </script>
</head>
<body>
<div id="app">
    <el-container>
<!--        <el-header>-->

<!--        </el-header>-->
        <el-main>
            <el-table
                    :data="others"
                    stripe
                    style="width: 500px">
                <el-table-column
                        prop="name"
                        label="名称"
                        width="100">
                </el-table-column>
                <el-table-column
                        prop="value"
                        label="值"
                        width="250">
                </el-table-column>
                <el-table-column
                        label="操作"
                        width="120">
                    <template slot-scope="scope">
                        <el-button
                                id="copyMe"
                                @click="copy(scope.$index, others)"
                                type="text"
                                size="small">
                            复制
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-main>
        <el-footer></el-footer>
    </el-container>
</div>
</body>
<!--@click="copy(scope.$index, codes)"-->
<!-- 先引入 Vue -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js"></script>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            others: []
        },
        methods: {
            send() {

                var token = encrypt(Date.parse(new Date()));
                axios({
                    method: 'get',
                    url: 'iccid.php',
                    params: {
                        token: token
                    },
                    responseType: 'json'
                }).then(function (response) {
                    console.log(response.data);
                    var iccid = response.data.iccid;
                    app.others.push({name:'iccid',value:iccid});

                });
            },
            copy(index, data) {
                var clipboard = new ClipboardJS("#copyMe", {
                    text: function () {
                        //寻找被激活的那个div pre元素,同时获取它下面的内容
                        //alert(data[index]['value']);
                        return data[index]['value'];
                    }
                });

                clipboard.on('success', function (e) {
                    alert("已复制到粘贴板！");
                    console.log(e);
                });

                clipboard.on('error', function (e) {
                    console.log(e);
                });
            }
        },
        mounted() {
            this.send()
        }
    });

</script>
</html>